package com.onpositive.html.model;

public class HyperLink {
	
	public HyperLink(String link,String caption) {
		super();
		this.caption = caption;
		this.link = link;
	}

	private String caption;
	
	private String link;

	public String getCaption() {
		return caption;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((caption == null) ? 0 : caption.hashCode());
		result = prime * result + ((link == null) ? 0 : link.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		HyperLink other = (HyperLink) obj;
		if (caption == null) {
			if (other.caption != null)
				return false;
		} else if (!caption.equals(other.caption))
			return false;
		if (link == null) {
			if (other.link != null)
				return false;
		} else if (!link.equals(other.link))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		StringBuilder bld= new StringBuilder();
		bld.append("<a href=");
		bld.append(link!=null?link:"null");
		bld.append(">");
		bld.append(caption!=null?caption:"null");
		bld.append("</a>");
		String str = bld.toString();
		return str;
	}

}
